import Vue from "vue";
import VueRouter from "vue-router";

const Home = () => import(/* webpackChunkName: "home" */ "../views/Home");
const Login = () => import(/* webpackChunkName: "Login" */ "../views/Login");
const PhoneLogin = () => import(/* webpackChunkName: "PhoneLogin" */ "../views/Login/phoneLogin.vue");
const Find = ()=>import(/* webpackChunkName: "find" */ "../views/Find");
const Search = ()=>import(/* webpackChunkName: "Sraech" */ "../views/Search");
const SearchResult = ()=>import(/* webpackChunkName: "SearchResult" */ "../views/SearchResult");
const Singer = ()=>import(/* webpackChunkName: "Singer" */ "../views/Singer");

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "home",
    component: Home,
    redirect:'/find',
    children:[
      {
        path:"/find",
        name:"find",
        component:Find
      }
    ]
  },
  {
    path:"/login",
    name:"login",
    component:Login
  },
  {
    path:"/phoneLogin",
    name:"phoneLogin",
    component:PhoneLogin
  },
  {
    path:"/search",
    name:"search",
    component:Search
  },
  {
    path:"/search_result",
    name:"searchResult",
    component:SearchResult
  },
  {
    path:"/singer",
    name:"Singer",
    component:Singer
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

router.beforeEach((to, from, next) => {
  // console.log(to.path)
  next()
})

export default router;
